package com.pft.web.view.baseui;

import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.Window;

public abstract class BaseUIActivity extends BaseActivity {
    public void clearAllFragment() {
        if (getSupportFragmentManager().getBackStackEntryCount() != 0) {
            getSupportFragmentManager().popBackStack(getSupportFragmentManager().getBackStackEntryAt(0).getId(), 1);
        }
    }

    protected abstract void clearMemory();


    protected abstract void initData();

    public void onContentChanged() {
        super.onContentChanged();
        initData();
    }

    protected void onCreate(Bundle paramBundle) {
        super.onCreate(paramBundle);
    }

    protected void onDestroy() {
        clearMemory();
        super.onDestroy();
    }

    protected void onPause() {
        super.onPause();
    }

    protected void onResume() {
        super.onResume();
    }

    protected void onStop() {
        super.onStop();
    }

    public void popBackStack() {
        if (getSupportFragmentManager().getBackStackEntryCount() == 1) {
            return;
        }
        getSupportFragmentManager().popBackStack();
    }

    protected void replaceFragment(Fragment paramFragment, int paramInt) {
        FragmentTransaction localFragmentTransaction = getSupportFragmentManager().beginTransaction();
        localFragmentTransaction.replace(paramInt, paramFragment);
        localFragmentTransaction.addToBackStack(null);
        localFragmentTransaction.commitAllowingStateLoss();
    }

    @TargetApi(21)
    protected void setStatusBarColor(int paramInt) {
        if (Build.VERSION.SDK_INT > 19) {
            Window localWindow = getWindow();
            localWindow.clearFlags(67108864);
            localWindow.addFlags(Integer.MIN_VALUE);
            localWindow.setStatusBarColor(paramInt);
        }
    }
}
